package com.yuzhenxin.coursesystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yuzhenxin.coursesystem.entity.TeacherDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface TeacherMapper extends BaseMapper<TeacherDO> {

    // 教师男女比例及总数
    @Select("select SUM(CASE WHEN sex = '男' THEN 1 ELSE 0 END)AS man," +
            "SUM(CASE WHEN sex = '女' THEN 1 ELSE 0 END) AS woman," +
            "count(1) as total from teacher")
    Map<String, Object> teacherCounts();

    // 教师职称男女比例
    @Select("select professional_title,SUM(CASE WHEN sex = '男' THEN 1 ELSE 0 END) AS man," +
            "SUM(CASE WHEN sex = '女' THEN 1 ELSE 0 END) AS woman from teacher " +
            "group by professional_title")
    List<Map<String, Object>> selectTeacherOrderByTpt();

}
